<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input v-model="listQuery.key" style="width: 25%;" class="filter-item" placeholder="输入关键字搜索" @keyup.enter.native="handleFilter" />
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
        搜索
      </el-button>
    </div>

    <div class="tab-container" style="margin-top: 30px">

    </div>
  </div>
</template>

<script>
import { fetchList } from '@/api/article'

export default {
  data() {
    return {
      listQuery: {
        page: 1,
        limit: 20,
        key: undefined,
        sort: '+id'
      }
    }
  },
  methods: {
    getList() {
      // this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total

        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    }
  }
}
</script>

<style scoped lang="scss">
.app-container {
  margin-top: 30px;
  margin-left: 2rem;
  margin-right: 2rem;
  border-radius: 15px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);

  .filter-container {
    margin-right: 30px;
    margin-left: 30px;
    margin-top: 30px;
  }
}
</style>
